import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'logic.dart';

class EquityPage extends StatelessWidget {
  final logic = Get.find<EquityLogic>();
  final state = Get.find<EquityLogic>().state;
  final int length = 10;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(centerTitle: false, title: const Text("资产管理")),
      body: Container(
        margin: const EdgeInsets.symmetric(horizontal: 10),
        child: ListView.builder(
          itemCount: length,
          itemBuilder: (context, index) {
            return _buildEquityItemWidget(index);
          },
        ),
      ),
    );
  }

  Widget _buildEquityItemWidget(int index) {
    return Card(
      margin: EdgeInsets.only(top: index == 0 ? 10 : 0, bottom: 10),
      child: Container(
        padding: const EdgeInsets.all(15),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            const Text("债务"),
            _buildEquityContentWidget(),
          ],
        ),
      ),
    );
  }

  Widget _buildEquityContentWidget() {
    return ListView.builder(
      itemCount: 5,
      itemExtent: 50,
      shrinkWrap: true,
      physics: const NeverScrollableScrollPhysics(),
      itemBuilder: (context, index) {
        return _buildEquityChildItemWidget();
      },
    );
  }

  Widget _buildEquityChildItemWidget() {
    return SizedBox(
      height: 50,
      child: Row(
        children: [
          Image.asset(
            "assets/images/logo.png",
            width: 30,
            height: 30,
          ),
          const Padding(
            padding: EdgeInsets.symmetric(horizontal: 10),
            child: Text("总借入"),
          ),
          const Spacer(),
          const Text("¥0.00"),
        ],
      ),
    );
  }
}
